// ==UserScript==
// @name         超星刷评论
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  超星简单刷评论
// @author       yk
// @grant        unsafeWindow
// @match        *://*.chaoxing.com/*
// @icon         
// @grant        none
// ==/UserScript==

// 要刷的条数
var num = 55;
var button = document.createElement("button"); //创建一个input对象（提示框按钮）
button.id = "id001";
button.style.height = "20px";
button.style.align = "center";
button.textContent = "开始刷评论";
button.disabled = true;

button.onclick = function (){
    sessionStorage.removeItem('num');
    // 这个地方也得修改
    num = 55
    sessionStorage.setItem('num',num);
    startRun()
    return;
};

(function() {
    'use strict';
    window.onload=function(){
    setTimeout(()=>{
            document.getElementsByClassName("newRight")[0].appendChild(button)
            if(sessionStorage.getItem('num')!=null){
                num = sessionStorage.getItem('num')
            }
            if(num <=0){
                document.getElementById("id001").disabled = false
                return
            }else{
                startRun()
            }
    },1000)
};

    // Your code here...
})();

function startRun(){
    document.getElementById("toplevelTextCommentTitle").value = num.toString()
    num --
    console.log(num)
    sessionStorage.setItem('num',num)
    document.getElementsByClassName("newBtn")[0].children[1].onclick()
}